﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TransportLayer
{
    public class Tokener
    {
        private List<string> tokens;

        private int currentItem = -1;

        public int Lenght { get { return tokens.Count;  } }


        public string CurrentToken { get { if (currentItem >= 0 && currentItem < tokens.Count) return tokens[currentItem]; else return "";  } }

        public Tokener()
        {
            tokens = new List<string>();
        }

        public void Reset()
        {
            currentItem = tokens.Count-1;
        }

        public void Put(string token)
        {
            tokens.Add(token);
            currentItem = tokens.Count;
        }

        public void MoveUp()
        {
            if (tokens.Count == 0)
                return;

                if(currentItem > 0)
                currentItem--;
                        
        }

        public void MoveDown()
        {
            if (tokens.Count == 0)
                return;

                if(currentItem<tokens.Count)
                currentItem++;

        }

    }
}
